/*HHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHH
 H    process_queue.h
 H    Application name:  tcss422-project2
 H    Programmers names:   Evan Phillips, Lucas Cowell, Tony Butterfield
 H    Date created:  May 9, 2011
 H    Date completed:  June 2,2011
 H    Brief Description: An implementation of a queue of processes for the simulation of an OS
 H        scheduler.  It will be used to construct the IO devices' and Semaphores' blocked
 H        queues as well as the Scheduler's Ready queue.
 H
 HHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHH*/

/* 'guard' macro... guarantees that this .h will only be included once */
#ifndef PROCESS_QUEUE_H_
#define PROCESS_QUEUE_H_
#endif /* PROCESS_QUEUE_H_ */

//#ifndef BOOLEAN
//#define BOOLEAN     unsigned char
//#define TRUE        1
//#define FALSE       0
//#endif /* BOOLEAN */

/* FORWARD DEFINITIONS - resolves circular dependencies */
struct process_str;     // forward definitiion of process


/***************************************************************************************************
 *  ADT: Process Queue
 * 	Description:  A queue that holds pointers to the processes that are being handled by the
 *          simulation.
 *
 *  Implementation:  Uses a linked structure as a backing store.
 *
 ***************************************************************************************************/

/*$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$
 $ Typedefs
 $$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$*/
typedef struct queue_node_str           // typedefs for QueueNode
{
    struct queue_node_str* next;
    struct process_str* data;
} QueueNodeStr;
typedef QueueNodeStr* QueueNode;

typedef struct process_queue_str        // typedefs for queue of QueueNodes
{
   QueueNode first;
   QueueNode last;
   int size;
} ProcQueueStr;
typedef ProcQueueStr* ProcessQueue;

/*-------------------------------------------------------------------------------------------------
 - Prototypes
 -		Initialize - creates an empty queue and returns a pointer.
 - 		Terminate - deallocates memory.
 -		Enqueue - adds new process pointer to end of queue.
 - 		Dequeue - gets first process pointer from head of queue.
 - 		Peek - returns first process pointer in queue, leaving it in the queue.
 -		Size - returns number of processes in queue.
 -		isEmpty - returns true if the queue is empty.
 ---------------------------------------------------------------------------------------------------*/
ProcessQueue    p_queue_init();                                 // initialize empty queue
int 	        p_queue_free(ProcessQueue);                     // deallocate queue
int             p_queue_enqueue(ProcessQueue, struct process_str*); // add process pointer to queue
struct process_str* p_queue_dequeue(ProcessQueue, int*);            // get process pointer from queue
struct process_str* p_queue_peek(ProcessQueue, int*);               // peek at first process in queue
int             p_queue_size(ProcessQueue, int*);               // get number of process pointers
BOOLEAN         p_queue_isEmpty(ProcessQueue, int*);            // returns TRUE if queue is empty

